I'm getting an issue where if I access a website I'm making via www.example.com/page then the browser fails to initialize the web workers.
From what I've read this is expected behaviour for security purposes. And that's fine, but I anticipate some people will be coming to the site via www.example.com while others will just type in example.com, and I'll need both to be able to access all the site's resources.
I figure the easy way to do this is to change www.example.com from an @ record to a CNAME record, redirecting all calls to https://www.example.com/page instead to https://example.com/page
I did that last night, and the TTL on the old record was only 30m, so even the world's slowest DNS caches should have been updated by now.
But if I try to access the site via www.example.com I'm still getting the same domain origin error.
What am I missing here? And most importantly, how can I make this work?
CNAME records are not HTTP redirects.
The browser looks for www.example.com, makes a DNS lookup for it, and the underlying DNS client gets told that the IP address is the same as example.com's, so it gets example.com's IP address and then makes an HTTP request to that IP address asking for www.example.com.
The origin will still be https://www.example.com.
Configure your HTTP server to issue a 301 Moved Permanently redirect for any requests for www.example.com instead.